import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument
from launch_ros.actions import Node


def generate_launch_description():
    bringup_dir = get_package_share_directory("video_sim_cam")
    params_file = LaunchConfiguration("params_file")

    declare_params_file_cmd = DeclareLaunchArgument(
        "params_file",
        default_value=os.path.join(bringup_dir, "config", "launch_params.yaml"),
        description="config file for video_sim_cam",
    )

    node = Node(
        package="video_sim_cam",
        executable="video_sim_cam_node",
        name="video_sim_cam",
        output="screen",
        parameters=[params_file],
    )

    launch_des = LaunchDescription()

    launch_des.add_action(declare_params_file_cmd)
    launch_des.add_action(node)

    return launch_des
